<template>
    <view class="simple-address data-v-42159e6c" v-if="showPopup">
        <view
            @tap="__e"
            :class="['simple-address-mask', 'data-v-42159e6c', ani + '-mask', animation ? 'mask-ani' : '']"
            :data-event-opts="[['tap', [['hideMask', [true]]]]]"
            :style="'background-color:' + maskBgColor + ';'"
            v-if="maskClick"
        ></view>
        <view :class="['simple-address-content', 'simple-address--fixed', 'data-v-42159e6c', type, ani + '-content', animation ? 'content-ani' : '']">
            <view class="simple-address__header data-v-42159e6c">
                <view @tap="__e" class="simple-address__header-btn-box data-v-42159e6c" :data-event-opts="[['tap', [['pickerCancel', ['$event']]]]]">
                    <text class="simple-address__header-text data-v-42159e6c" :style="'color:' + cancelColor + ';' + 'font-size:' + btnFontSize + ';'">取消</text>
                </view>
                <view @tap="__e" class="simple-address__header-btn-box data-v-42159e6c" :data-event-opts="[['tap', [['pickerConfirm', ['$event']]]]]">
                    <text class="simple-address__header-text data-v-42159e6c" :style="'color:' + (confirmColor || themeColor) + ';' + 'font-size:' + btnFontSize + ';'">确定</text>
                </view>
            </view>
            <view class="simple-address__box data-v-42159e6c">
                <picker-view
                    @change="__e"
                    class="simple-address-view data-v-42159e6c"
                    :data-event-opts="[['change', [['pickerChange', ['$event']]]]]"
                    indicatorStyle="height: 50rpx; color: black;"
                    :value="pickerValue"
                >
                    <picker-view-column class="data-v-42159e6c">
                        <view class="picker-item data-v-42159e6c" :style="'font-size:' + fontSize + ';'" v-for="(item, index) in provinceDataList" :key="index">
                            {{ item.label }}
                        </view>
                    </picker-view-column>
                    <picker-view-column class="data-v-42159e6c">
                        <view class="picker-item data-v-42159e6c" :style="'font-size:' + fontSize + ';'" v-for="(item, index) in cityDataList" :key="index">{{ item.label }}</view>
                    </picker-view-column>
                    <picker-view-column class="data-v-42159e6c">
                        <view class="picker-item data-v-42159e6c" :style="'font-size:' + fontSize + ';'" v-for="(item, index) in areaDataList" :key="index">{{ item.label }}</view>
                    </picker-view-column>
                </picker-view>
            </view>
        </view>
    </view>
</template>

<script>
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['components/AreaSelect/simple-address'],
    {
        '2c95': function (e, t, i) {
            'use strict';

            i.r(t);
            var a = i('84ea');
            var n = i.n(a);
            for (var u in a) {
                if (['default'].indexOf(u) < 0) {
                    (function (e) {
                        i.d(t, e, function () {
                            return a[e];
                        });
                    })(u);
                }
            }
            t.default = n.a;
        },
        '39db': function (e, t, i) {
            'use strict';

            i.r(t);
            var a = i('b427');
            var n = i('2c95');
            for (var u in n) {
                if (['default'].indexOf(u) < 0) {
                    (function (e) {
                        i.d(t, e, function () {
                            return n[e];
                        });
                    })(u);
                }
            }
            i('4a81');
            var l = i('f0c5');
            var c = Object(l.a)(n.default, a.b, a.c, false, null, '42159e6c', null, false, a.a, void 0);
            t.default = c.exports;
        },
        '4a81': function (e, t, i) {
            'use strict';

            var a = i('5de8');
            i.n(a).a;
        },
        '5de8': function (e, t, i) {},
        '84ea': function (e, t, i) {
            'use strict';

            (function (e) {
                var a = i('4ea4');
                Object.defineProperty(t, '__esModule', {
                    value: true
                });
                t.default = void 0;
                var n = a(i('6eb0'));
                var u = a(i('97cf'));
                var l = a(i('29fe'));
                var c = {
                    name: 'simpleAddress',
                    props: {
                        mode: {
                            type: String,
                            default: 'default'
                        },
                        animation: {
                            type: Boolean,
                            default: true
                        },
                        type: {
                            type: String,
                            default: 'bottom'
                        },
                        maskClick: {
                            type: Boolean,
                            default: true
                        },
                        show: {
                            type: Boolean,
                            default: true
                        },
                        maskBgColor: {
                            type: String,
                            default: 'rgba(0, 0, 0, 0.4)'
                        },
                        themeColor: {
                            type: String,
                            default: ''
                        },
                        cancelColor: {
                            type: String,
                            default: ''
                        },
                        confirmColor: {
                            type: String,
                            default: ''
                        },
                        fontSize: {
                            type: String,
                            default: '28rpx'
                        },
                        btnFontSize: {
                            type: String,
                            default: ''
                        },
                        pickerValueDefault: {
                            type: Array,
                            default: function () {
                                return [0, 0, 0];
                            }
                        }
                    },
                    data: function () {
                        return {
                            ani: '',
                            showPopup: false,
                            pickerValue: [0, 0, 0],
                            provinceDataList: [],
                            cityDataList: [],
                            areaDataList: []
                        };
                    },
                    watch: {
                        show: function (e) {
                            if (e) {
                                this.open();
                            } else {
                                this.close();
                            }
                        },
                        pickerValueDefault: function () {
                            this.init();
                        }
                    },
                    created: function () {
                        this.init();
                    },
                    methods: {
                        clickView: function () {
                            e.showToast({
                                title: '进行中'
                            });
                        },
                        init: function () {
                            this.handPickValueDefault();
                            this.provinceDataList = n.default;
                            this.cityDataList = u.default[this.pickerValueDefault[0]];
                            this.areaDataList = l.default[this.pickerValueDefault[0]][this.pickerValueDefault[1]];
                            this.pickerValue = this.pickerValueDefault;
                        },
                        handPickValueDefault: function () {
                            if (this.pickerValueDefault !== [0, 0, 0]) {
                                if (this.pickerValueDefault[0] > n.default.length - 1) {
                                    this.pickerValueDefault[0] = n.default.length - 1;
                                }
                                if (this.pickerValueDefault[1] > u.default[this.pickerValueDefault[0]].length - 1) {
                                    this.pickerValueDefault[1] = u.default[this.pickerValueDefault[0]].length - 1;
                                }
                                if (this.pickerValueDefault[2] > l.default[this.pickerValueDefault[0]][this.pickerValueDefault[1]].length - 1) {
                                    this.pickerValueDefault[2] = l.default[this.pickerValueDefault[0]][this.pickerValueDefault[1]].length - 1;
                                }
                            }
                        },
                        pickerChange: function (e) {
                            var t = e.detail.value;
                            if (this.pickerValue[0] !== t[0]) {
                                (this.cityDataList = u.default[t[0]]), (this.areaDataList = l.default[t[0]][0]), (t[1] = 0), (t[2] = 0);
                            } else {
                                if (this.pickerValue[1] !== t[1]) {
                                    (this.areaDataList = l.default[t[0]][t[1]]), (t[2] = 0);
                                }
                            }
                            this.pickerValue = t;
                            this._$emit('onChange');
                        },
                        _$emit: function (e) {
                            var t = {
                                label: this._getLabel(),
                                value: this.pickerValue,
                                cityCode: this._getCityCode(),
                                areaCode: this._getAreaCode(),
                                provinceCode: this._getProvinceCode(),
                                labelArr: this._getLabel().split('-')
                            };
                            this.$emit(e, t);
                        },
                        _getLabel: function () {
                            return (
                                this.provinceDataList[this.pickerValue[0]].label +
                                '-' +
                                this.cityDataList[this.pickerValue[1]].label +
                                '-' +
                                this.areaDataList[this.pickerValue[2]].label
                            );
                        },
                        _getCityCode: function () {
                            return this.cityDataList[this.pickerValue[1]].value;
                        },
                        _getProvinceCode: function () {
                            return this.provinceDataList[this.pickerValue[0]].value;
                        },
                        _getAreaCode: function () {
                            return this.areaDataList[this.pickerValue[2]].value;
                        },
                        queryIndex: function () {
                            if (arguments.length > 0 && void 0 !== arguments[0]) {
                                var e = arguments[0];
                            } else {
                                var e = [];
                            }
                            if (arguments.length > 1 && void 0 !== arguments[1]) {
                                var t = arguments[1];
                            } else {
                                var t = 'value';
                            }
                            var i = n.default.findIndex(function (i) {
                                return i[t] == e[0];
                            });
                            var a = u.default[i].findIndex(function (i) {
                                return i[t] == e[1];
                            });
                            var c = l.default[i][a].findIndex(function (i) {
                                return i[t] == e[2];
                            });
                            return {
                                index: [i, a, c],
                                data: {
                                    province: n.default[i],
                                    city: u.default[i][a],
                                    area: l.default[i][a][c]
                                }
                            };
                        },
                        clear: function () {},
                        hideMask: function () {
                            this._$emit('onCancel');
                            this.close();
                        },
                        pickerCancel: function () {
                            this._$emit('onCancel');
                            this.close();
                        },
                        pickerConfirm: function () {
                            this._$emit('onConfirm');
                            this.close();
                        },
                        open: function () {
                            var that = this;
                            this.showPopup = true;
                            this.$nextTick(function () {
                                setTimeout(function () {
                                    that.ani = 'simple-' + that.type;
                                }, 100);
                            });
                        },
                        close: function (e) {
                            var that = this;
                            (!this.maskClick && e) ||
                                ((this.ani = ''),
                                this.$nextTick(function () {
                                    setTimeout(function () {
                                        that.showPopup = false;
                                    }, 300);
                                }));
                        }
                    }
                };
                t.default = c;
            }.call(this, i('543d').default));
        },
        b427: function (e, t, i) {
            'use strict';

            i.d(t, 'b', function () {
                return a;
            });
            i.d(t, 'c', function () {
                return n;
            });
            i.d(t, 'a', function () {});
            var a = function () {
                this.$createElement;
                this._self._c;
            };
            var n = [];
        }
    }
]);
(global.webpackJsonp = global.webpackJsonp || []).push([
    'components/AreaSelect/simple-address-create-component',
    {
        'components/AreaSelect/simple-address-create-component': function (e, t, i) {
            i('543d').createComponent(i('39db'));
        }
    },
    [['components/AreaSelect/simple-address-create-component']]
]);
</script>
<style>
@import './simple-address.css';
</style>
